<template>
  <div>
    <!-- 整个容器 -->
    <el-container>
      <!-- 上半部分：顶栏 -->
      <el-header class="layout-header">
        <div class="login-user">
          <span class="welcome">欢迎回来，root！</span>
          <el-dropdown>
            <el-avatar src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"
            ></el-avatar>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item icon="el-icon-plus">修改资料</el-dropdown-item>
              <el-dropdown-item icon="el-icon-circle-plus">修改头像</el-dropdown-item>
              <el-dropdown-item icon="el-icon-circle-plus-outline">修改密码</el-dropdown-item>
              <el-dropdown-item icon="el-icon-check" divided>退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
        <!-- 左侧的标题文字 -->
        <h1>云课堂管理平台</h1>
      </el-header>
      <!-- 下半部分 -->
      <el-container class="layout-body">
        <!-- 下半部分的左侧：侧边栏 -->
        <el-aside class="layout-aside" style="width: 220px">
          <el-menu
              router
              :default-active="activeMenuItemPath"
              class="el-menu-vertical-demo"
              background-color="#eaedf1"
              text-color="#666666"
              active-text-color= "#666666">
            <!-- 首页 -->
            <el-menu-item index="1">
              <i class="el-icon-s-home"></i>
              <span slot="title">首页</span>
            </el-menu-item>
            <!-- 轮播管理 -->
            <el-menu-item index="2">
              <i class="el-icon-picture"></i>
              <span slot="title">轮播管理</span>
            </el-menu-item>
            <!-- 课程管理 -->
            <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-collection"></i>
                <span>课程管理</span>
              </template>
              <el-menu-item index="3-1">
                <i class="el-icon-s-grid"></i>
                <span slot="title">课程列表</span>
              </el-menu-item>
              <el-menu-item index="3-2">
                <i class="el-icon-s-check"></i>
                <span slot="title">课程审核</span>
              </el-menu-item>
              <el-menu-item index="3-3">
                <i class="el-icon-menu"></i>
                <span slot="title">分类管理</span>
              </el-menu-item>
            </el-submenu>
            <!-- 讲师管理 -->
            <el-submenu index="4">
              <template slot="title">
                <i class="el-icon-user-solid"></i>
                <span>讲师管理</span>
              </template>
              <el-menu-item index="4-1">
                <i class="el-icon-s-grid"></i>
                <span slot="title">讲师列表</span>
              </el-menu-item>
              <el-menu-item index="4-2">
                <i class="el-icon-s-check"></i>
                <span slot="title">讲师审核</span>
              </el-menu-item>
            </el-submenu>
            <!-- 学员管理 -->
            <el-menu-item index="5">
              <i class="el-icon-s-custom"></i>
              <span slot="title">学员管理</span>
            </el-menu-item>
            <!-- 用户管理 -->
            <el-menu-item index="6">
              <i class="el-icon-s-custom"></i>
              <span slot="title">用户管理</span>
            </el-menu-item>
            <!-- 订单管理 -->
            <el-menu-item index="7">
              <i class="el-icon-tickets"></i>
              <span slot="title">订单管理</span>
            </el-menu-item>
            <!-- 评论管理 -->
            <el-menu-item index="8">
              <i class="el-icon-chat-dot-square"></i>
              <span slot="title">评论管理</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <!-- 下半部分的右侧：主体 -->
        <el-main class="layout-main">

          <router-view/>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeMenuItemPath: ''
    };
  },
  methods: {
    handleActiveMenuItem() {
      let currentPath = this.$router.currentRoute.path;



      this.activeMenuItemPath = currentPath;
    }
  },
  mounted() {
    this.handleActiveMenuItem();
  }
}
</script>

<style>
.layout-header {
  background: #304156;
}

.layout-header h1 {
  line-height: 60px;
  color: #fff;

}

.layout-header .login-user {
  float: right;
  display: flex;
  margin-top: 10px;
}

.layout-header .login-user .welcome {
  line-height: 40px;
  color: #fff;
}

.layout-body {
  position: absolute;
  top: 60px;
  bottom: 0px;
  left: 0px;
  right: 0px;
}

.layout-aside {
  background: #eaedf1;
}

.layout-aside i {
  color: #666666 !important;
}

.el-menu-item.is-active{
  background: #2c3e50 !important;
}

.layout-main {
  background: #fff;
}
</style>
